package calc

class Computable[T](f: List[T] => T, paramCount: Int){
	def compute(stack: List[T]) = f( stack.take(paramCount) ) :: stack.drop(paramCount)
}

object Computable{
	def apply[T](t: T) = 
		new Computable( (d: List[T]) => t, 0)

	def apply[T](f: T => T) = 
		new Computable( (d: List[T]) => f(d(0)), 1)

	def apply[T](f: (T, T) => T) = 
		new Computable( (d: List[T]) => f(d(1), d(0)), 2)
}